package cn.iocoder.yudao.module.pay.refund.controller.app;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.module.pay.refund.service.PayRefundService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Tag(name = "用户 App - 退款单据")
@RestController
@RequestMapping("/pay/refund")
@Validated
public class AppPayRefundController {
    @Resource
    private PayRefundService refundService;

    @RequestMapping(value = "/notify/{channelCode}", method = {RequestMethod.GET, RequestMethod.POST})
    @Operation(summary = "回调地址", description = "主要用于微服务架构，单体架构已进行内部事件监听")
    @PermitAll // 回调无需登录限制
    @ApiAccessLog(responseEnable = true)
    public String refundBackPost(@PathVariable("channelCode") String channelCode, @RequestParam(required = false) Map<String, String> params, @RequestBody(required = false) String body, @RequestHeader(required = false) Map<String, String> headers) {
        return refundService.notify(channelCode, params, body, headers);
    }

}
